import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wanchong/conf.dart';
import 'package:wanchong/utils/common.dart';

class AnimNick extends StatefulWidget {
  @override
  _AnimNickState createState() => _AnimNickState();
}

class _AnimNickState extends State<AnimNick> {
  TextEditingController _controller = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomPadding: false,
      appBar: AppBar(
        elevation: 0,
        leading: BackButtonIcon(),
        title: Center(
          child: Text(
            "修改昵称",
            style: TextStyle(
              color: Color(MainColor),
              fontSize: 18,
              fontWeight: FontWeight.w700,
            ),
          ),
        ),
        actions: <Widget>[
          GestureDetector(
            onTap: () {
              if (_controller.text.length > 0) {
                Navigator.pop(context, _controller.text);
              } else {
                alert("请填写昵称~");
              }
            },
            child: Container(
              color: Colors.transparent,
              padding: EdgeInsets.only(left: 15.0, right: 15.0),
              child: Center(
                child: Text(
                  "完成",
                  style: TextStyle(color: Color(MainColor), fontSize: 14),
                ),
              ),
            ),
          )
        ],
      ),
      body: Container(
        height: double.infinity,
        padding: EdgeInsets.only(
          top: ScreenUtil.getInstance().setHeight(15.0),
        ),
        // color: Colors.white,
        width: double.infinity,
        child: TextField(
          controller: _controller,
          style: TextStyle(
            color: Color(MainColor),
            fontSize: ScreenUtil.getInstance().setSp(14),
          ),
          decoration: InputDecoration(
            hintText: "请输入昵称",
            focusedBorder: InputBorder.none,
            border: InputBorder.none,
            fillColor: Colors.white,
            suffix: GestureDetector(
              onTap: () {
                setState(() {
                  _controller.text = "";
                });
              },
              child: Container(
                color: Colors.transparent,
                padding: EdgeInsets.only(left: 15.0, right: 15.0),
                child: Icon(
                  Icons.close,
                  color: Color(0xFFB4BEC6),
                  size: 12.0,
                ),
              ),
            ),
            filled: true,
            contentPadding:
                EdgeInsets.only(left: 15.0, top: 20.0, bottom: 20.0),
          ),
        ),
      ),
    );
  }
}
